package com.blrs.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.blrs.common.core.page.PageDomain;
import com.blrs.common.core.page.TableSupport;
import com.blrs.common.utils.SecurityUtils;
import com.blrs.common.utils.page.PaginationUtil;
import com.blrs.domain.ElectricSalesInfo;
import com.blrs.service.enterprise.person.IEnterprisePersonInfoService;
import com.blrs.system.service.ISysDeptService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.blrs.common.annotation.Log;
import com.blrs.common.core.controller.BaseController;
import com.blrs.common.core.domain.AjaxResult;
import com.blrs.common.enums.BusinessType;
import com.blrs.domain.EnterprisePersonInfo;
import com.blrs.common.utils.poi.ExcelUtil;
import com.blrs.common.core.page.TableDataInfo;

/**
 * 企业人员管理Controller
 * 
 * @author ruoyi
 * @date 2023-07-19
 */
@RestController
@RequestMapping("/enterprise/person")
public class EnterprisePersonInfoController extends BaseController
{
    @Autowired
    private IEnterprisePersonInfoService enterprisePersonInfoService;
    @Autowired
    private ISysDeptService sysDeptService;
    /**
     * 查询企业人员管理列表
     */
    //@PreAuthorize("@ss.hasPermi('enterprise:person:list')")
    @GetMapping("/list")
    public TableDataInfo list(EnterprisePersonInfo enterprisePersonInfo)
    {
        startPage();
        enterprisePersonInfo.setOrganizationId(SecurityUtils.getOrgId());
        List<EnterprisePersonInfo> list = enterprisePersonInfoService.selectEnterprisePersonInfoList(enterprisePersonInfo);
        return getDataTable(list);


    }

    /**
     * 获取企业人员管理详细信息
     */
    //@PreAuthorize("@ss.hasPermi('enterprise:person:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return success(enterprisePersonInfoService.selectEnterprisePersonInfoById(id));
    }

    /**
     * 新增企业人员管理
     */
    //@PreAuthorize("@ss.hasPermi('enterprise:person:add')")
    @Log(title = "人员信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody EnterprisePersonInfo enterprisePersonInfo)
    {
        return toAjax(enterprisePersonInfoService.insertEnterprisePersonInfo(enterprisePersonInfo));
    }

    /**
     * 修改企业人员管理
     */
    //@PreAuthorize("@ss.hasPermi('enterprise:person:edit')")
    @Log(title = "人员信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody EnterprisePersonInfo enterprisePersonInfo)
    {
        return toAjax(enterprisePersonInfoService.updateEnterprisePersonInfo(enterprisePersonInfo));
    }

    /**
     * 删除企业人员管理
     */
    //@PreAuthorize("@ss.hasPermi('enterprise:person:remove')")
    @Log(title = "人员信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(enterprisePersonInfoService.deleteEnterprisePersonInfoByIds(ids));
    }


}
